<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="/WEB-INF/component/commonTagLib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><spring:message code="message.listForm.qiYeChanPinKuGuanLi"/> <spring:message code="message.lable.compdrugprofileStd"/><spring:message code="message.button.add"/> <spring:message code="message.button.edit"/> </title>

<%@ include file="/WEB-INF/component/commonCSS.jsp" %> 


</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>${(opType==0)?"药品新增":"药品编辑"}</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.StdManage"/></a></li>
            <li class="active"><a href="#"><spring:message code="message.lable.proddruginfoStd"/></a></li>
        </ol>
    </section>
    <section class="content">
        <div class=" box box-success">
            <form  id="form1" class="form-horizontal" action="${ctx }/stdProdDrugInfo/saveCompSelfDrug.html?opType=${opType}" method="post">
               <input type="hidden" name="prodId" value="${detail.prodId}" />
	           <input type="hidden" name="opType" value="${opType}" />
	           <input type="hidden" name="status" value="${detail.status}" />
	           <input type="hidden" id="qualityspecId" name="qualityspecId" value="${detail.qualityspecId }">
	           <input type="hidden" id="prodCompId" name="prodCompId" value="${detail.prodCompId }">
	           <input type="hidden" id="prodCompCode" name="prodCompCode" value="${detail.prodCompCode }">
	           <input type="hidden" id="prodCompStatus" name="prodCompStatus" value="${detail.prodCompStatus }">
	           <input type="hidden" id="unit" name="unit" value="${detail.unit }">
	           <input type="hidden" id="unitCode" name="unitCode" value="${detail.unitCode }"> 
	           <input type="hidden" id="unitStatus" name="unitStatus" value="${detail.unitStatus }">  
	           <input type="hidden" id="materialId" name="materialId" value="${detail.materialId }">
	           <input type="hidden" id="materialCode" name="materialCode" value="${detail.materialCode }">
	           <input type="hidden" id="materialStatus" name="materialStatus" value="${detail.materialStatus }">
	           <input type="hidden" id="pharId" name="pharId" value="${detail.pharId }">
	           <input type="hidden" id="pharCode" name="pharCode" value="${detail.pharCode }">
	           <input type="hidden" id="pharStatus" name="pharStatus" value="${detail.pharStatus }">
           
                <div class="box-body">
                	<div class="box-header with-border">
	                 <h3 class="box-title"><spring:message code="message.listForm.YaoPinXinXi"/><spring:message code="message.yanZheng.maoHao"/>
	                    <span id="drugCode" style="color:#cccccc;font-size:15px;} " >${detail.drugCode}</span>
	                 </h3>
                 	</div>
                    <div class="form-group form-group-xs">
                        <%-- <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.yaoPinBianMa"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="drugCode" name="drugCode" value="${detail.drugCode}" placeholder="<spring:message code="message.listForm.yaoPinBianMa"/>" type="text" maxlength="10">
                        </div> --%>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.tongYongMing"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <input onclick="quality();" class="form-control" readonly="readonly" id="qualityspecName" name="qualityspecName" placeholder="<spring:message code="message.listForm.tongYongMing"/>" type="text" value="${detail.qualityspecName}">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><spring:message code="message.listForm.tongYongMingEnglish"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <input onclick="quality();"  class="form-control" readonly="readonly" id="qualityspecNameEng" name="qualityspecNameEng" value="${detail.qualityspecNameEng}" placeholder="<spring:message code="message.listForm.tongYongMingEnglish"/>" type="text">
                        </div>
                        
                        <label class="col-sm-2 text-right"><spring:message code="message.listForm.shangPinMing"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="busName" name="busName" value="${detail.busName}" placeholder="<spring:message code="message.listForm.shangPinMing"/>" type="text">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.jiXing"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <input onclick="quality();" class="form-control" readonly="readonly" id="formName" name="formName" placeholder="<spring:message code="message.listForm.jiXing"/>" type="text" value="${detail.formName}">
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.guiGe"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <input onclick="quality();" class="form-control" readonly="readonly" id="specName" name="specName" placeholder="<spring:message code="message.listForm.guiGe"/>" type="text" value="${detail.specName}">
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.zhuanHuanXiShu"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="factor" name="factor" placeholder="<spring:message code="message.listForm.zhuanHuanXiShuMeiYou"/>" value="${detail.factor }" type="text" maxlength="11">
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.baoZhuangDanWei"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <div class="col-sm-9">
                                <input onclick="stdUnit();" class="form-control" readonly="readonly" id="unitName" name="unitName" placeholder="<spring:message code="message.listForm.baoZhuangDanWei"/>" value="${detail.unitName }" type="text">
                            </div>
                            <div id="addUnit" class="col-sm-3 btn btn-default btn-sm"><spring:message code="message.button.addSpacing"/></div>
                        </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.caiZhi"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                             <div class="col-sm-9">
                                <input onclick="material();" class="form-control" readonly="readonly" id="materialName" name="materialName" placeholder="<spring:message code="message.listForm.caiZhi"/>" value="${detail.materialName }" type="text">
                             </div>
                             <div id="addMaterial" class="col-sm-3 btn btn-default btn-sm"><spring:message code="message.button.addSpacing"/></div>
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.yaoPinBenWeiMa"/><spring:message code="message.yanZheng.maoHao"/></label>
                         <div class="col-sm-4 text-left">
                               <input class="form-control" id="drugStdCode" name="drugStdCode" placeholder="<spring:message code="message.listForm.yaoPinBenWeiMa"/>" type="text" value="${detail.drugStdCode }" maxlength="42">
                         </div>
                    </div>
                    
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.piZhunWenHao"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="approvalCode" name="approvalCode" placeholder="<spring:message code="message.listForm.piZhunWenHao"/>" type="text" value="${detail.approvalCode }" maxlength="100">
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.piZhunRiQi"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                         <input class="form-control" type="text" id="approvalDate" name="approvalDate" value="${detail.approvalDate }"  placeholder="yyyy-MM-dd" data-provide="datepicker" data-date-fmt="yyyy-MM-dd" />
                        </div>
                    </div>
                   
                    <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.jiBenYaoWuShuXing"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <select class="form-control" id="drugAttr" name="drugAttr">
                                <option value=""><spring:message code="message.select.option"/></option>
                                <option value="1" ${ detail.drugAttr == 1 ? "selected='selected'" : "" } ><spring:message code="message.listForm.guoJiaJiBenYaoWu"/></option>
                                <option value="2" ${ detail.drugAttr == 2 ? "selected='selected'" : "" } ><spring:message code="message.listForm.shengZengBuJiBenYaoWu"/></option>
                                <option value="3" ${ detail.drugAttr == 3 ? "selected='selected'" : "" } ><spring:message code="message.listForm.qiTa"/></option>
                            </select>
                        </div>
                        
                        <label class="col-sm-2 text-right"><spring:message code="message.listForm.jiYaoXuHao"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <input class="form-control" id="drugIndex" name="drugIndex" placeholder="<spring:message code="message.listForm.jiYaoXuHao"/>" type="text" value="${detail.drugIndex }" />
                        </div>
                    </div>
                        
                   <div class="form-group form-group-xs">
                      <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.YaoLiFenLei"/><spring:message code="message.yanZheng.maoHao"/></label>
                      <div class="col-sm-4 text-left">
                            <input onclick="dicPhar();" class="form-control" readonly="readonly" id="pharName" name="pharName" placeholder="<spring:message code="message.listForm.YaoLiFenLei"/>" value="${detail.pharName}" type="text">
                       </div>
                      
                       <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.zhuanLiLeiXing"/><spring:message code="message.yanZheng.maoHao"/></label>
                       <div class="col-sm-4 text-left">
                           <select class="form-control" id="patternType" name="patternType">
                                <option value=""><spring:message code="message.select.option"/></option>
                                <option value="1" ${ detail.patternType == 1 ? "selected='selected'" : "" } ><spring:message code="message.listForm.faMingZhuanLi"/></option>
                                <option value="2" ${ detail.patternType == 2 ? "selected='selected'" : "" } ><spring:message code="message.listForm.shiYongXinXingZhuanLi"/></option>
                                <option value="3" ${ detail.patternType == 3 ? "selected='selected'" : "" } ><spring:message code="message.listForm.waiGuanSheJiZhuanLi"/></option>
                                <option value="4" ${ detail.patternType == 4 ? "selected='selected'" : "" } ><spring:message code="message.listForm.meiYouZhuanLi"/></option>
                                <option value="9" ${ detail.patternType == 9 ? "selected='selected'" : "" } ><spring:message code="message.listForm.buXiang"/></option>
                           </select>
                       </div>
                   </div>
                        
                   <div class="form-group form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.yaoPinLaiYuan"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                                <select class="form-control" id="drugSource" name="drugSource">
                                    <option value=""><spring:message code="message.select.option"/></option>
                                    <option value="1" ${ detail.drugSource == 1 ? "selected='selected'" : "" } ><spring:message code="message.listForm.guoChan"/></option>
                                    <option value="2" ${ detail.drugSource == 2 ? "selected='selected'" : "" } ><spring:message code="message.listForm.jinKou"/></option>
                                    <option value="9" ${ detail.drugSource == 9 ? "selected='selected'" : "" } ><spring:message code="message.listForm.buXiang"/></option>
                                </select>
                            
                        </div>
                        
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.shiFouDiJiaYao"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                            <select class="form-control" id="isLowprice" name="isLowprice">
                                <option value=""><spring:message code="message.select.option"/></option>
                                <option value="1" ${ detail.isLowprice == 1 ? "selected='selected'" : "" } ><spring:message code="message.listForm.shi"/></option>
                                <option value="0" ${ detail.isLowprice == 0 ? "selected='selected'" : "" } ><spring:message code="message.listForm.fou"/></option>
                                <option value="9" ${ detail.isLowprice == 9 ? "selected='selected'" : "" } ><spring:message code="message.listForm.WeiZhi"/></option>
                            </select>
                        </div>
                   </div>
                        
                   <div class="form-group  form-group-xs">
                        <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.shiFouNongHe"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="col-sm-4 text-left">
                             <select class="form-control" id="isAgriculture" name="isAgriculture">
                                 <option value=""><spring:message code="message.select.option"/></option>
                                 <option value="1" ${ detail.isAgriculture == 1 ? "selected='selected'" : "" } ><spring:message code="message.listForm.shi"/></option>
                                 <option value="0" ${ detail.isAgriculture == 0 ? "selected='selected'" : "" } ><spring:message code="message.listForm.fou"/></option>
                                 <option value="9" ${ detail.isAgriculture == 9 ? "selected='selected'" : "" } ><spring:message code="message.listForm.WeiZhi"/></option>
                             </select>
                         </div>
                         
                         <label class="col-sm-2 text-right"><span class="required">*</span><spring:message code="message.listForm.shiFouYiBao"/><spring:message code="message.yanZheng.maoHao"/></label>
                         <div class="col-sm-4 text-left">
                              <select class="form-control" id="isHealthcare" name="isHealthcare">
                                   <option value=""><spring:message code="message.select.option"/></option>
                                   <option value="1" ${ detail.isHealthcare == 1 ? "selected='selected'" : "" } ><spring:message code="message.listForm.shi"/></option>
                                   <option value="0" ${ detail.isHealthcare == 0 ? "selected='selected'" : "" } ><spring:message code="message.listForm.fou"/></option>
                                   <option value="9" ${ detail.isHealthcare == 9 ? "selected='selected'" : "" } ><spring:message code="message.listForm.WeiZhi"/></option>
                              </select>
                         </div>
                    </div>
                        
                     <div class="form-group form-group-xs">
                          <label class="col-sm-2 text-right"><spring:message code="message.listForm.yaoPinBenWeiMaBeiZhu"/><spring:message code="message.yanZheng.maoHao"/></label>
                          <div class="col-sm-10 text-left">
                               <textarea class="form-control" id="drugStdcdRemark" name="drugStdcdRemark" rows="3" placeholder="<spring:message code="message.listForm.yaoPinBenWeiMaBeiZhu"/>" >${detail.drugStdcdRemark }</textarea> 
                          </div>
                     </div>
                       
                     <div class="form-group form-group-xs">
                          <label class="col-sm-2 text-right"><spring:message code="message.listForm.shuoMing"/><spring:message code="message.yanZheng.maoHao"/></label>
                          <div class="col-sm-10 text-left">
                               <textarea class="form-control" id="remark" name="remark" rows="3" placeholder="<spring:message code="message.listForm.shuoMing"/> ...">${detail.remark }</textarea>
                          </div>
                     </div>
                     
                     <div class="box-footer text-center">
                        <button type="button" onclick="save();" class="btn btn-success btn-sm"><spring:message code="message.button.saveSpacing"/></button>
                        <a href="${ctx}/stdProdDrugInfo/toCompSelfDrugList.html" class="btn btn-danger btn-sm"><spring:message code="message.button.getBackSpacing"/></a>
                     </div>
                </div>
            </form>
        </div>
        
        <div class="modal fade" id="materialModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header bg-primary">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h5 class="modal-title" id="exampleModalLabel"><spring:message code="message.listForm.caiZhi"/><spring:message code="message.button.add"/></h5>
                    </div>
                    <div class="modal-body">
                     <form>
                     <div class="form-group form-group-xs">
                        <label for="material-code" class=" control-label"><span class="required">*</span><spring:message code="message.listForm.caiZhi"/><spring:message code="message.yanZheng.bianMa"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="">
                            <input type="text" class="form-control" id="material-code" placeholder="<spring:message code="message.listForm.caiZhi"/><spring:message code="message.yanZheng.bianMa"/>" maxlength="10" />
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="material-name" class=" control-label"><span class="required">*</span><spring:message code="message.listForm.caiZhi"/><spring:message code="message.listForm.mingCheng"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="">
                            <input type="text" class="form-control" id="material-name" placeholder="<spring:message code="message.listForm.caiZhi"/><spring:message code="message.listForm.mingCheng"/>" maxlength="50" />
                        </div>
                    </div>
                    </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" onclick="saveMaterial();" class="btn btn-primary btn-sm"><spring:message code="message.button.saveSpacing"/></button>
                        <button type="button" class="btn btn-danger btn-sm" data-dismiss="modal"><spring:message code="message.button.closeSpacing"/></button>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="modal fade" id="unitModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header bg-primary">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h5 class="modal-title" id="exampleModalLabel"><spring:message code="message.listForm.baoZhuangDanWei"/><spring:message code="message.button.add"/></h5>
                    </div>
                    <div class="modal-body">
                     <form>
                     <div class="form-group form-group-xs">
                        <label for="unit-code" class=" control-label"><span class="required">*</span><spring:message code="message.listForm.baoZhuangDanWei"/><spring:message code="message.yanZheng.bianMa"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="">
                            <input type="text" class="form-control" id="unit-code" placeholder="<spring:message code="message.listForm.baoZhuangDanWei"/><spring:message code="message.yanZheng.bianMa"/>" maxlength="10" >
                        </div>
                    </div>
                    <div class="form-group form-group-xs">
                        <label for="unit-name" class=" control-label"><span class="required">*</span><spring:message code="message.listForm.baoZhuangDanWei"/><spring:message code="message.listForm.mingCheng"/><spring:message code="message.yanZheng.maoHao"/></label>
                        <div class="">
                            <input type="text" class="form-control" id="unit-name" placeholder="<spring:message code="message.listForm.baoZhuangDanWei"/><spring:message code="message.listForm.mingCheng"/>" maxlength="50" >
                        </div>
                    </div>
                    </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" onclick="saveUnit();" class="btn btn-primary btn-sm"><spring:message code="message.button.saveSpacing"/></button>
                        <button type="button" class="btn btn-danger btn-sm" data-dismiss="modal"><spring:message code="message.button.closeSpacing"/></button>
                    </div>
                </div>
            </div>
        </div>
        
    </section>
    <%@ include file="/WEB-INF/component/commonJS.jsp" %> 
    <script type="text/javascript">
    
    //加载页面光标在名字框内，位于第一个
    $("#drugCode").focus();
    
        
        //新增
	    $('#addMaterial').click(function () {
	        $('#material-code').val("");
	        $('#material-name').val("");
	        $('#materialModal').modal({
	            keyboard: true
	        });
	    });
        
	    $('#addUnit').click(function () {
            $('#unit-code').val("");
            $('#unit-name').val("");
            $('#unitModal').modal({
                keyboard: true
            });
        });
        //材质新增
        function saveMaterial() {
        	var materialName = $.trim($("#material-name").val());
            var materialCode = $.trim($("#material-code").val());
            
            if(materialCode == null || materialCode == ""){
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.caiZhi"/><spring:message code="message.yanZheng.bianMa"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
                return false;
            }
            if(!/^[a-zA-Z0-9_]+$/.test(materialCode)){
                $.alert("<spring:message code="message.listForm.caiZhi"/><spring:message code="message.yanZheng.bianMa"/><spring:message code="message.yanZheng.zhiNengYouZiMuShuZiZuCheng"/>", "warn");
                return false;
            }
            if(materialName == null || materialName == ""){
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.caiZhi"/><spring:message code="message.listForm.mingCheng"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
                return false;
            }
            
            $.HN.message.confirm('<spring:message code="message.HN.alert.OkSaveYESorNO"/>', '', '').on(function (e) {
               if (e) {
                   $.ajax({
                      type: "POST",
                      url: "${ctx}/dicDrugmaterial/add.html",
                      data: "materialCode="+materialCode+"&materialName="+materialName,
                      dataType:"json",
                      success: function(result){
                          if(result.success){
                        	  $.alert("<spring:message code="message.HN.alert.baoCunCheng"/>", "success");
                              $('#materialModal').modal('hide');
                              $("#materialCode").val(materialCode);
                              $("#materialName").val(materialName);
                              $("#materialStatus").val(1);
                          }else{
                              $.alert(result.msg || "<spring:message code="message.HN.alert.baoCunBai"/>", "error");
                          }
                      }
                   });
               }
           });
        }
        //包装单位新增
        function saveUnit() {
        	var packunitName = $("#unit-name").val();
            var packunitCode = $("#unit-code").val();
            
            if(packunitCode == ""){
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.baoZhuangDanWei"/><spring:message code="message.yanZheng.bianMa"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
                return false;
            }
            if(!/^[a-zA-Z0-9_]+$/.test(packunitCode)){
                $.alert("<spring:message code="message.listForm.baoZhuangDanWei"/><spring:message code="message.yanZheng.bianMa"/><spring:message code="message.yanZheng.zhiNengYouZiMuShuZiZuCheng"/>", "warn");
                return false;
            }
            
            if(packunitName == ""){
                $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.baoZhuangDanWeiMingCheng"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
                return false;
            }
            
            $.HN.message.confirm('<spring:message code="message.HN.alert.OkSaveYESorNO"/>', '', '').on(function (e) {
               if (e) {
                   $.ajax({
                      type: "POST",
                      url: "${ctx}/dicPackunit/add.html",
                      data: {
                          packunitCode:packunitCode,
                          packunitName:packunitName
                      },
                      dataType:"json",
                      success: function(result){
                          if(result.success){
                              $.alert("<spring:message code="message.HN.alert.baoCunCheng"/>", "success");
                              $('#unitModal').modal('hide');
                              $("#unitCode").val(packunitCode);
                              $("#unitName").val(packunitName);
                              $("#unitStatus").val(1);
                          }else{
                              $.alert(result.msg || "<spring:message code="message.HN.alert.baoCunBai"/>", "error");
                          }
                      }
                   });
               }
           });
        }
    
         //保存
         function save() {
            if (!validate()) {
                return;
            }  
            $.HN.message.confirm('<spring:message code="message.HN.alert.OkSaveYESorNO"/>', '', '').on(function (e) {
               if (e) {
                        $("#form1").ajaxSubmit({
                            dataType : "json",
                            timeout: 10000,
                            success : function(result, statusText) {
                                if (result.success) {
                                	var opType = ${opType==0};
			    					if(opType){
			    						$.alert("为您新增一条编码为"+result.msg+"的药品", "success");
			    					}else {
			    						$.alert("<spring:message code='message.HN.alert.baoCunCheng'/>", "success");
			    					}
			    					document.location = "${ctx}/stdProdDrugInfo/toCompSelfDrugList.html";
                                   /*  $.alert("<spring:message code="message.HN.alert.baoCunCheng"/>", "success", function() {
                                        document.location = "${ctx}/stdProdDrugInfo/toCompSelfDrugList.html";
                                    }); */
                                } else {
                                    $.alert(result.msg || "<spring:message code="message.HN.alert.baoCunBai"/>", "error");
                                }
                            }
                        });
                   }
              });
            
        }
        
      
      
      
    //通用名、剂型、规格弹窗
      function quality(){
            var url = "${ctx}/stdProdDrugInfo/toSelectQualityspec.html";
          $.HN.dialog.open({
              "id": "quality",
              "title": "<spring:message code="message.list.drugqualityspecStdlist"/>", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                	  $("#qualityspecId").val(params.qualityspecId);
                      $("#specName").val(params.specName);
                      $("#formName").val(params.formName);
                      $("#qualityspecName").val(params.qualityspecName);
                      $("#qualityspecNameEng").val(params.qualityspecNameEng);
                  }
              }
          });   
      }
      
       //药理分类 弹窗
      function dicPhar() {
           var url = "${ctx}/stdProdDrugInfo/toSelectPhar.html";
          $.HN.dialog.open({
              "id": "dicPhar",
              "title": "<spring:message code="message.list.pharDiclist"/>", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                	  $("#pharName").val(params.pharName);
                      $("#pharId").val(params.pharId);
                      $("#pharCode").val(params.pharCode);
                      $("#pharStatus").val(params.pharStatus);
                  }
              }
          }); 
      }
  
    //材质  弹窗
      function material() {
           var url = "${ctx}/stdProdDrugInfo/toSelectMaterial.html";
          $.HN.dialog.open({
              "id": "material",
              "title": "<spring:message code="message.list.drugmaterialDiclist"/>", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                	  $("#materialName").val(params.materialName);
                      $("#materialId").val(params.materialId);
                      $("#materialCode").val(params.materialCode);
                      $("#materialStatus").val(params.materialStatus);
                  }
              }
          }); 
      }
    
      //包装单位  弹窗
      function stdUnit() {
           var url = "${ctx}/stdProdDrugInfo/toSelectUnit.html";
          $.HN.dialog.open({
              "id": "stdUnit",
              "title": "<spring:message code="message.list.packunitDiclist"/>", 
              "url": url, 
              "data": {}, 
              "width": 800, 
              "height": 510, 
              "closefunc":function(params) {
                  if (params) {
                	  $("#unitName").val(params.unitName);
                      $("#unit").val(params.unitId);
                      $("#unitCode").val(params.unitCode);
                      $("#unitStatus").val(params.unitStatus);
                  }
              }
          }); 
      }
      
      
      
    //效验
      function validate() {
          
          /* var drugCode = $.trim($("#drugCode").val());
          if (drugCode == null || drugCode == "") {
              $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.yaoPinBianMa"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          } else if (!/^[a-zA-Z0-9_]+$/.test(drugCode)) {
              $.alert("<spring:message code="message.listForm.yaoPinBianMa"/><spring:message code="message.yanZheng.zhiNengYouZiMuShuZiZuCheng"/>", "warn");
              return false;
          }else if (drugCode.length > 128) {
              $.alert("<spring:message code="message.listForm.yaoPinBianMa"/><spring:message code="message.info.zuiDaChangDu"/>128<spring:message code="message.info.geZiFu"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          } */
          
          var qualityspecName = $.trim($("#qualityspecName").val());
          if (qualityspecName == null || qualityspecName == "") {
              $.alert("<spring:message code="message.listForm.dianJiXuanZe"/><spring:message code="message.listForm.tongYongMing"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var formName = $.trim($("#formName").val());
          if (formName == null || formName == "") {
              $.alert("<spring:message code="message.listForm.dianJiXuanZe"/><spring:message code="message.listForm.jiXing"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var busName = $.trim($("#busName").val());
          if (busName != null && busName != "" && busName.length >256 ) {
              $.alert("<spring:message code="message.listForm.shangPinMing"/><spring:message code="message.info.zuiDaChangDu"/>256<spring:message code="message.info.geZiFu"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var specName = $.trim($("#specName").val());
          if (specName == null || specName == "") {
              $.alert("<spring:message code="message.listForm.dianJiXuanZe"/><spring:message code="message.listForm.guiGe"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var factor = $.trim($("#factor").val());
          if (factor == null || factor == "") {
              $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.zhuanHuanXiShu"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }else if (!/^[0-9]+$/.test(factor)) {
              $.alert("<spring:message code="message.listForm.zhuanHuanXiShu"/><spring:message code="message.listForm.zhiNengShuZiZuCheng"/>", "warn");
              return false;
          }else if (factor.length >11 ) {
              $.alert("<spring:message code="message.listForm.zhuanHuanXiShu"/><spring:message code="message.info.zuiDaChangDu"/>11<spring:message code="message.info.geZiFu"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }

		  var drugStdCode = $.trim($("#drugStdCode").val());
          if (drugStdCode == null || drugStdCode == "") {
              $.alert("<spring:message code="message.yanZheng.qingShuRu"/><spring:message code="message.listForm.yaoPinBenWeiMa"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }else if (!/[A-Za-z0-9]+$/.test(drugStdCode)) {
              $.alert("<spring:message code="message.listForm.yaoPinBenWeiMa"/><spring:message code="message.lable.zhiNengYiShuZiZiMuZuCheng"/>", "warn");
              return false;
          }else if (drugStdCode.length >100 ) {
              $.alert("<spring:message code="message.listForm.yaoPinBenWeiMa"/><spring:message code="message.info.zuiDaChangDu"/>100<spring:message code="message.info.geZiFu"/>", "warn");
              return false;
          }
          
          var unit = $.trim($("#unitName").val());
          if (unit == null || unit == "") {
              $.alert("<spring:message code="message.listForm.dianJiXuanZe"/><spring:message code="message.listForm.huoXinZeng"/><spring:message code="message.listForm.baoZhuangDanWei"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var materialName = $.trim($("#materialName").val());
          if (materialName == null || materialName == "") {
              $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.huoXinZeng"/><spring:message code="message.listForm.caiZhi"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var approvalCode = $.trim($("#approvalCode").val());
          if (approvalCode == null || approvalCode == "") {
              $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.piZhunWenHao"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;  
          }else if (!/[A-Za-z0-9]+$/.test(approvalCode)) {
              $.alert("<spring:message code="message.listForm.approvalCode"/><spring:message code="message.lable.zhiNengYiShuZiZiMuZuCheng"/>", "warn");
              return false;
          }else if (approvalCode.length >100 ) {
              $.alert("<spring:message code="message.listForm.piZhunWenHao"/><spring:message code="message.info.zuiDaChangDu"/>100<spring:message code="message.info.geZiFu"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var approvalDate = $.trim($("#approvalDate").val());
          if (approvalDate == null || approvalDate == "") {
              $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.piZhunRiQi"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var drugAttr = $.trim($("#drugAttr").val());
          if (drugAttr == null || drugAttr == "") {
              $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.jiBenYaoWuShuXing"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
         var drugIndex = $.trim($("#drugIndex").val());
          if (drugIndex != null && drugIndex != "" && !/^[0-9]+$/.test(drugIndex)) {
              $.alert("<spring:message code="message.listForm.jiYaoXuHao"/><spring:message code="message.listForm.zhiNengShuZiZuCheng"/>", "warn");
              return false;
          }else if (drugIndex.length >100 ) {
              $.alert("<spring:message code="message.listForm.jiYaoXuHao"/><spring:message code="message.info.zuiDaChangDu"/>100<spring:message code="message.info.geZiFu"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          } 
          
          var pharName = $.trim($("#pharName").val());
          if (pharName == null || pharName == "") {
              $.alert("<spring:message code="message.listForm.dianJiXuanZe"/><spring:message code="message.listForm.YaoLiFenLei"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var patternType = $.trim($("#patternType").val());
          if (patternType == null || patternType == "") {
              $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.zhuanLiLeiXing"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var drugSource = $.trim($("#drugSource").val());
          if (drugSource == null || drugSource == "") {
              $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.yaoPinLaiYuan"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var isLowprice = $.trim($("#isLowprice").val());
          if (isLowprice == null || isLowprice == "") {
              $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.shiFouDiJiaYao"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var isAgriculture = $.trim($("#isAgriculture").val());
          if (isAgriculture == null || isAgriculture == "") {
              $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.shiFouNongHe"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
          var isHealthcare = $.trim($("#isHealthcare").val());
          if (isHealthcare == null || isHealthcare == "") {
              $.alert("<spring:message code="message.select.option"/><spring:message code="message.listForm.shiFouYiBao"/><spring:message code="message.yanZheng.ganTanHao"/>", "warn");
              return false;
          }
          
           

          return true;
      }
       
    </script>
</body>
</html>